using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using Shine.Framework;
using System.Configuration;

using SuperMap.Data;
using SuperMap.Realspace;

namespace Shine.FlyManager
{
 
    internal class Stop : BaseCommand
    {
        IApplication m_Application = null;
        SuperMap.Realspace.FlyManager fm = null;

        public Stop()
        {
            base.m_caption = "ֹͣ";
            base.m_name = "Stop";
            base.m_toolTip = "ֹͣ";
            base.m_message = "ֹͣ";
            base.m_category = "FlyManager";
            base.m_enabled = false;
        }

        public override void OnCreate(object hook)
        {
            if (m_Application == null)
            {
                m_Application = hook as IApplication;
                (m_Application as IFramework).SceneControl.Scene.FlyManager.StatusChanged += FlyManager_StatusChanged;
            }
        }

        private void FlyManager_StatusChanged(object sender, StatusChangedEventArgs e)
        {
            //throw new System.NotImplementedException();
            if (e.CurrentStatus == FlyStatus.Play)
            {
                base.m_enabled = true;
            }
            else if (e.CurrentStatus == FlyStatus.Stop || e.CurrentStatus == FlyStatus.Pause)
            {
                base.m_enabled = false;
            }
        }

        public override void OnClick()
        {
            fm = (m_Application as IFramework).SceneControl.Scene.FlyManager;
            if (fm.Status != FlyStatus.Stop) fm.Stop();
        }

        public override int Bitmap
        {
            get
            {
                string imgFile = Application.StartupPath + "\\Images\\" + GetType().Name + ".png";

                if (System.IO.File.Exists(imgFile) == false) return 0;

                return new Bitmap(Image.FromFile(imgFile)).GetHbitmap().ToInt32();
            }
        }


        public override bool Enabled
        {
            get 
            { //return (m_Application as IFramework).IsMapCtrlactive;
                return base.m_enabled;
            }
        }
    }
}